﻿using System.Windows;
using System.Windows.Controls;
using MangaUtils;

namespace MangaReader
{
	/// <summary>
	/// Small window which provides option to select volume which you want to read.
	/// </summary>
	public partial class OpenVolume : Window
	{
		private Manga manga;
		public OpenVolume(Manga manga)
		{
			InitializeComponent();

			this.manga = manga;
			foreach (var volume in manga.ProjectFolder.Subfolders)
			{
				volComboBox.Items.Add(volume.ToString());
			}			
		}

		private void volComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			string volumeSelected = (string)volComboBox.SelectedItem;
			int selIndex = volComboBox.SelectedIndex;
			string selVolPath = manga.ProjectFolder.Path + @"\" + volumeSelected;
			foreach (var chapter in manga.ProjectFolder.Subfolders[selIndex].Subfolders)
			{
				chapComboBox.Items.Add(chapter.ToString());
			}
			chapComboBox.Items.Add("All chapters");
		}

		private void openBtn_Click(object sender, RoutedEventArgs e)
		{
			DialogResult = true;
			Close();
		}
	}
}
